﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Xml.Serialization;

namespace TED.Model
{
    public class TEDVideo
    {
        string _title = null;
        string _author = null;
        Uri _imageUrl = null;
        string _viewUrl = null;
        string _videoUrl = null;


        public event PropertyChangedEventHandler PropertyChanged;
        /*
        public TEDVideo(string title, string author, Uri imageUrl, string viewUrl, string videoUrl)
        {
            Title = title;
            Author = author;
            ImageUrl = imageUrl;
            ViewUrl = viewUrl;
            VideoUrl = videoUrl;
        }

        public TEDVideo()
        {
            ;
        }
        */
        public void OnPropertyChanged(string str)
        {

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(str));
            }
        }


        public string Title
        {
            get { return _title; }
            set
            {
                _title = value;
                //OnPropertyChanged("Title");
            }
        }

        public string Author
        {
            get { return _author; }
            set
            {
                _author = value;
               // OnPropertyChanged("Author");
            }
        }

        [XmlIgnore]
        public Uri ImageUrl
        {
            get { return _imageUrl; }
            set
            {
                _imageUrl = value;
                //OnPropertyChanged("ImageUrl");
            }
        }

        [XmlElement("ImageUrl")]
        public string ImageUrlAsString
        {
            get { return ImageUrl != null ? ImageUrl.AbsoluteUri : null; }
            set { ImageUrl = value != null ? new Uri(value) : null; }
        }

        public string ViewUrl
        {
            get { return _viewUrl; }
            set { _viewUrl = value; }
        }

        public string VideoUrl
        {
            get { return _videoUrl; }
            set { _videoUrl = value; }
        }
    }
}
